﻿var domarr = [];
jQuery.dialog = {
  /*
  *消息框
  */
  alert: function (text,arg) {
	  closeDialog();
    var opt = $.extend({},setting_default,arg);
    var $window = $('<div class="windowcenter"></div>');
    $window.css({ "position": "fixed","border": "1px solid rgb(207, 206, 206)", "width": "300px", "display": "none", "margin": "0 auto 0 -150px", "padding": "2px",
      "top": "10px", "left": "50%", "border-radius": "10px", "-webkit-border-radius": "0.6em", "-moz-border-radius": "10px",
      "background-color": "#f1f1f1", "-webkit-box-shadow": "0 0 10px rgba(0, 0, 0, 0.5)", "-moz-box-shadow": "0 0 10px rgba(0, 0, 0, 0.5)",
      "-o-box-shadow": "0 0 10px rgba(0, 0, 0, 0.5)", "box-shadow": "0 0 10px rgba(0, 0, 0, 0.5)",
      "font": "14px/1.5 Microsoft YaHei, Helvitica, Verdana, Arial, san-serif", "z-index": "10"
    });
    var $title = $('<div>'+opt.title+'</div>');
    $title.css({ "background-color": "#585858", "line-height": "26px", "padding": "5px 5px 5px 10px", "color": "#fff", "font-size": "1em",
      "border-radius": "0.5em 0.5em 0 0", "-webkit-border-radius": "0.5em 0.5em 0 0", "-moz-border-radius": "0.5em 0.5em 0 0"
    });
    var $close = $('<span></span>');
    $close.css({ "float": "right", "width": "26px", "height": "26px", "display": "block", "background-image": "url('data:image/png;base64," +
        "iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACTSURBVEhL7dNtCoAgD" +
        "AZgb60nsGN1tPLVCVNHmg76kQ8E1mwv+GG27cestQ4PvTZ69SFocBGpWa8+zHt/Up+IN+MhgLlUmnIE1CpBQB2COZibfpnXhHFaIZkYph0SOeeK/QJ8o7KOek84fkCWSBtfL+N" +
        "y2MPpCkPFMH6PWEhWhKncIyEk69VfiUuVhqJefds+YcwNbEwxGqGIFWYAAAAASUVORK5CYII=')"
    });
    $close.click(function () {
      if ($(".windowcenter").length > 0) {
        $(".windowcenter").slideUp(500);
		 $(".overlay").remove();
		 opt.ok();
      }
    });
    $title.append($close);
    $window.append($title);
    var $content = $('<div></div>');
    $content.css({ "overflow": "auto", "padding": "10px", "color": "#222", "text-shadow": "0 1px 0 #FFFFFF" });
    var $text = $('<div></div>');
    $text.css({ "min-height": "30px", "font-size": "16px", "line-height": "20px" });
    $text.text(text);
    $content.append($text);
    $window.append($content);
    closeDialog();
    $("body").append(overlay).append($window);
    $(".windowcenter").slideDown("slow");
    setTimeout(function(){$(".windowcenter").slideUp(500,function(){
	 $(".overlay").remove();opt.ok()
	}); }, 1000*opt.time);
  },
 alertTxt: function (text,arg) {
	  var opt = $.extend({},setting_default,arg);
	 if ( $(".windowcenter2").size() > 0)
	 {
$(".windowcenter2").text(text);
$("#"+opt.id).css("border","1px solid red");
if ( $.inArray(opt.id,domarr) == -1)
{
	domarr.push(opt.id);
	$("#"+opt.id).click(function(){
	  $(this).css("border","0px");
	  domarr.remove(opt.id);
	  $(".windowcenter2").remove();
	});
}
return;
	 }
    
    var $window = $('<div class="windowcenter2"></div>');
    $window.css({ "position": "fixed","border": "1px solid rgb(207, 206, 206)", "width": "100%","height":"40px",
      "top": "0px","font": "14px/1.5 Microsoft white, Helvitica, Verdana, Arial, san-serif","text-align":"center",
		"z-index": "10","background":"orange","line-height":"40px","color":"white"
    });
    $window.text(text);
    //$content.append($text);
    //$window.append($text);
    $("body").append($window);
	$("#"+opt.id).css("border","1px solid red");
	if ( $.inArray(opt.id,domarr) == -1)
{
	domarr.push(opt.id);
	$("#"+opt.id).click(function(){
	  $(this).css("border","0px");
	  domarr.remove(opt.id);
	  $(".windowcenter2").remove();
	});
}
  }, // 带自动关闭的tip
 alerttxt: function (text,arg) {
	  closeDialog();
	  var opt = $.extend({},setting_default,arg);
	    var $window = $('<div class="windowcenter"></div>');
	    $window.css({ "position": "fixed","border": "1px solid rgb(207, 206, 206)", "width": "100%","height":"40px",
	      "top": "0px","font": "14px/1.5 Microsoft white, Helvitica, Verdana, Arial, san-serif","text-align":"center",
			"z-index": "10","background":"orange","line-height":"40px","color":"white"
	    });
    $window.text(text);
    //$content.append($text);
    //$window.append($text);
	if (opt.overlay)
	{
		$("body").append($(".overlay"));
	}
    $("body").append($window);
    setTimeout(function(){$(".windowcenter").slideUp(500,function(){
    	$(".windowcenter").remove();
   	 $(".overlay").remove();opt.ok()
   	}); }, 1000*opt.time);
  },
 /**
  *加载框
  *
  */
  loading:function(msg){
	  closeDialog();
	  if (msg == undefined)
	  {
		  msg = "loading";
	  }
	  //msg = msg | "loading";
  // var opt = $.extend({},setting_default,arg);
var $popTips = $('<div class="windowcenter" style="display: block;"></div>');
    $popTips.css({ "position": "fixed","z-index": "300", "left": "50%", "top": "40%", "width": "60px", "overflow": "hidden",
      "margin-left": "-30px",    "background-color":"#F8F5F5", "line-height":"40px","font-size": "1.0em", "text-align": "center", "border-radius": "5px"
    });//"background-color": "#FBFBFB",

   var $img = $('<img src="'+
   '/0CAcEgUDAgFA8BQIAwExKh0eEAkrlcA9oo4TKcKwharHScIiu9wwTBn3QnGQg1owBNld+O72N/zZnVzRApteFsODwoQABAKDw5bZQxpQ2JkCRESahIRh1gEVIGVamlmXgBWWxETdEMTnlsIAAJmm65DEmZGYw64UZFbR2MPv0QPY0hjpMYKY0ljjMZCEGNK09MG0diN1gXL3M5bTcTcyFtOvdzBWE+207pjUKpYrL+wY7MAB4EerqZjUAG4lKVCBwMbvnT6dCXUkEIFK0jUkOECFEeQJF2hFKUPAIkgQwIaI+hLiJAoR27Zo4YBCJQgVW4cpMYDBpgVZKL59cEBhw+U+QROQ4bBAoUlTZ7QCQIAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfju9jf82Z1c0QKbXhbDg8KEAAQCg8OW2UMaUNiZAkREmoSEYdYBFSBlWppZl4AVlsRE3RDE55bCAACZpuuQxJmRmMOuFGRW0djD79ED2NIY6TGCmNJY4zGQhBjStPTFBXb21DY1VsGFtzbF9gAzlsFGOQVGefIW2LtGhvYwVgDD+0V17+6Y6BwaNfBwy9YY2YBcMAPnStTY1B9YMdNiyZOngCFGuIBxDZAiRY1eoTvE6UoDEIAGrNSUoNBUuzAaYlljxo2M+HIeXiJpRsRNMaq+JSFCpsRJEqYOPH2JQgAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfjywjlzX9jdXNEHiAVFX8ODwoQABAKDw5bZQxpQh8YiIhaERJqEhF4WwRDDpubAJdqaWZeAByoFR0edEMTolsIAA+yFUq2QxJmAgmyGhvBRJNbA5qoGcpED2MEFrIX0kMKYwUUslDaj2PA4soGY47iEOQFY6vS3FtNYw/m1KQDYw7mzFhPZj5JGzYGipUtESYowzVmF4ADgOCBCZTgFQAxZBJ4AiXqT6ltbUZhWdToUSR/Ii1FWbDnDkUyDQhJsQPn5ZU9atjUhCPHVhgTNy/RSKsiqKFFbUaQKGHiJNyXIAAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEh8JDAWCsBQIAwExKhU+HFwKlgsIMHlIg7TqQeTLW+7XYIiPGSAymY0mrFgA0LwuLzbCC/6eVlnewkADXVECgxcAGUaGRdQEAoPDmhnDGtDBJcVHQYbYRIRhWgEQwd7AB52AGt7YAAIchETrUITpGgIAAJ7ErdDEnsCA3IOwUSWaAOcaA/JQ0amBXKa0QpyBQZyENFCEHIG39HcaN7f4WhM1uTZaE1y0N/TacZoyN/LXU+/0cNyoMxCUytYLjm8AKSS46rVKzmxADhjlCACMFGkBiU4NUQRxS4OHijwNqnSJS6ZovzRyJAQo0NhGrgs5bIPmwWLCLHsQsfhxBWTe9QkOzCwC8sv5Ho127akyRM7QQAAOwAAAAAAAAAAAA=="  style="display: block;" />');
$img.css({ "width": "35px","height":"35px","marginLeft":"12px","margin-top":"5px"});
$popTips.append($img);
$div=$("<div style='margin-top:10px;color:teal'>"+msg+"</div>");
$popTips.append($div);
$("body").append(overlay).append($popTips);
  },
	  //文字加载
txtloading:function(msg){
	  closeDialog();
	  if (msg == undefined)
	  {
		  msg = "loading";
	  }
	  //msg = msg | "loading";
  // var opt = $.extend({},setting_default,arg);
var $popTips = $('<div class="windowcenter" style="display: block;">'+msg+'</div>');
    $popTips.css({ "position": "fixed","z-index": "300", "left": "50%", "top": "50%","height":"40px","margin-top":"-20px", "padding":"5px 10px", "overflow": "hidden",
       "background-color":"#000000", "font-size": "1.0em","color":"white","line-height":"40px", "text-align": "center", "border-radius": "5px"
    });//"background-color": "#FBFBFB",

$("body").append(overlay).append($popTips);
 $popTips.css("margin-left","-"+($popTips.width()/2)+"px");
  },
btxtloading:function(msg){
	  closeDialog();
	  if (msg == undefined)
	  {
		  msg = "loading";
	  }
	  //msg = msg | "loading";
  // var opt = $.extend({},setting_default,arg);
var $popTips = $('<div class="windowcenter" style="display: block;">'+msg+'</div>');
    $popTips.css({ "position": "fixed","z-index": "300", "left": "50%", "top": "40%","height":"40px", "padding":"5px 10px", "overflow": "hidden",
      "margin-left": "-30px",    "background-color":"#000000", "font-size": "1.0em","color":"white","line-height":"40px", "text-align": "center", "border-radius": "5px"
    });//"background-color": "#FBFBFB",
var overlay2 = "<div class='overlay' style='padding-right:20px;position:fixed;left:0px;top:0px;background-color: #000000;opacity: 0.7;filter: alpha(opacity = 70);width:"+(parseInt(jQuery(this).width())-20)+"px;height:"+parseInt(jQuery(this).height())+"px'></div>";
$("body").append(overlay2).append($popTips);
  },


ploading:function(msg){
	  if (msg == undefined)
	  {
		  msg = "loading";
	  }
	  //msg = msg | "loading";
  // var opt = $.extend({},setting_default,arg);
var $popTips = $('<div class="windowcenter" style="display: block;"></div>');
    $popTips.css({ "position": "fixed","z-index": "300", "left": "50%", "top": "40%", "width": "134px", "overflow": "hidden",
      "margin-left": "-66px",  "font-size": "16px", "background-color":"#F8F5F5", "text-align": "center", "border-radius": "5px"
    });//"background-color": "#FBFBFB",

   var $img = $('<img src="'+
   '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"  style="display: block;" />');
$img.css({ "width": "128px","height":"15px","margin-left":"3px","margini-top":"5px"});
$popTips.append($img);
$div=$("<div style='margin-top:10px;color:teal'>"+msg+"</div>");
$popTips.append($div);
$("body").append(overlay).append($popTips);
  },
  /*
   *对话框
   */
  message: function (text,arg) {
	  closeDialog();
	 var opt = $.extend({},setting_default,arg);
    var $popTips = $('<div class="windowcenter" style="display: block;"></div>');
    $popTips.css({ "position": "fixed","border": "1px solid rgb(207, 206, 206)","z-index": "300", "left": "50%", "top": "40%", "width": "80%", "overflow": "hidden",
      "margin-left": "-40%","margin-top":"-20px", "background-color": "#FBFBFB", "font-size": "16px", "text-align": "center", "border-radius": "5px"
    });
    $popTips.append('<div></div>');

    var $popShow = $('<div></div>');
    var $title = $('<h4>'+opt.title+'</h4>');
    $title.css({ "padding": "0", "margin": "0", "height": "34", "font-size": "16px", "border-bottom": "1px solid rgb(225, 218, 218)",
      "line-height": "34px", "color": "#252E32", "text-align":"left","text-indent":"15px"
    });
    $popShow.append($title);
    var txt = '<div style="padding:10% 0px">';
    if (opt.type != "no"){
    	//
    	txt+="<img src='/frame/images/"+opt.type+".png' style='margin-right:10px ;vertical-align: bottom;' />";
    }
    $text=$(txt+text+'</div>');
    $text.css({ "font-size": "16px", "padding": "20px 0px", "background-color": "#FFF" });
    $popShow.append($text);
    var $popBtns = $('<div></div>');
    $popBtns.css("text-align", "center");
    var a_css = { "display": "block", "font-weight": "700", "height": "40px", "line-height": "40px", "border-top": "1px solid #E2E1E0",
      "text-decoration": "none", "color": "#5B5B5B"
    };
    //取消事件或OK事件
   // var cancelEvent = function () {
    //  closeDialog();
   // }
    var $ok = $('<a href="javascript:void(0);">'+opt.positive+'</a>');
    $ok.css(a_css);
	$('body').append(overlay).append($popTips);
	//alert($popTips.width());
    //有取消按钮并且有确定的回调函数，设置确定后调用回调函数并追加取消按钮同时设定取消事件
    if (opt.cancel) {
      $ok.click(function(){
		closeDialog();
		opt.yes();
		
	  });
      //设置取消按钮和取消事件
	  var width = $popTips.width();
      $ok.css({ "width": ""+(width*0.5)+"px", "float": "right" });
      var $cancel = $('<a style="clear:both;width:'+((width*0.5)-2)+'px; float:left; border-right:1px solid #E2E1E0" href="javascript:void(0);">'+opt.navgative+'</a>');
      $cancel.css(a_css);
      $cancel.click(function(){
		 closeDialog();
		 opt.no();
	  });
      $popBtns.append($cancel);
    } else {
      $ok.click(function(){
		 
		closeDialog();
	    opt.ok();
	  });
    }
    $popBtns.append($ok);
    $popShow.append($popBtns);
    $popTips.append($popShow);
  }
}
//var isnew = true;
function closeDialog(){
	if ($(".windowcenter").length > 0) {
      $(".windowcenter").remove();
	  //$(".overlay").hide(300,function(){
	  // $(this).remove();
	 // });
	 $(".overlay").remove();
	// isnew = false;
    }
 // $("#windowcenter").remove();
  
}
var setting_default = {ok:function(){},yes:function(){},no:function(){

},time:2,cancel:false,title:"温馨提示",positive:"确定",navgative:"取消"}
var overlay = "<div class='overlay' style='z-index:100;position:fixed;left:0px;top:0px;background-color: #000000;opacity: 0.5;filter: alpha(opacity = 50);width:"+(parseInt(jQuery(this).width()))+"px;height:"+parseInt(jQuery(this).height())+"px'></div>";
//覆盖alert提示
window.alert=function(msg,arg){
  arg = arg == undefined?{}:arg;
 // confirm(JSON.stringify(arg));
  arg = $.extend({type:"info"},arg);
  $.dialog.message(msg,arg);
}
//确定对话框
function Wconfirm(msg,arg){
  arg = arg == undefined?{cancel:true}:arg;
  arg = $.extend({cancel:true},arg);
  $.dialog.message(msg,arg);
}
function Walert(msg,arg){
  arg = arg == undefined?{}:arg;
 // confirm(JSON.stringify(arg));
  arg = $.extend({type:"info"},arg);
  $.dialog.message(msg,arg);
}
//加载进度条
function Wloading(msg){
  $.dialog.loading(msg);
}

//第二种进度条
function Wploading(msg){
   $.dialog.ploading(msg);
}
function Wloading3(msg){
   $.dialog.txtloading(msg);
}
function Wbloading(msg){
   $.dialog.txtloading(msg);
}
//tip框
function Wtip(msg,arg){
	arg = arg == undefined?{}:arg;
   $.dialog.alert(msg,arg);
}
function Wtxt(msg,arg){
   $.dialog.alertTxt(msg,arg);
}
function Wtime(msg,arg){
   $.dialog.alerttxt(msg,arg);
}
Array.prototype.remove=function(dx) 
{ 
    if(isNaN(dx)||dx>this.length){return false;} 
    for(var i=0,n=0;i<this.length;i++) 
    { 
        if(this[i]!=this[dx]) 
        { 
            this[n++]=this[i] 
        } 
    } 
    this.length-=1 
}
//下拉执行函数
function Wrefresh(id,fn){
  document.addEventListener('touchstart',touch,false);
    document.addEventListener('touchmove',touch,false);
    document.addEventListener('touchend',touch,false);
     var startY = 0;
var isdo = 0;
var div = "<div id='txtre' style='display:block;width:100%;height:40px;text-align:center;color:white;background:black;font-size:14px;line-height:40px'>松开刷新...</div>";
    function touch (event){
//event.preventDefault();//阻止缩放
        var event = event || window.event;
//alert(event.type);
if (event.type == "touchstart"){
 startY = event.touches[0].screenY;
//document.title = startY;
}
if (event.type == "touchmove"){
var he = event.touches[0].screenY;
//document.title = he - startY;
if (he - startY < 100 && he-startY>0){
if (isdo == 0){
var first = $("#"+id);
 
$(div).insertBefore(first);
isdo = 1;
}
}
}
if (event.type == "touchend"){
if (isdo == 1)
{
	isdo = 0;
	$("#txtre").slideUp(600,function(){
	$(this).remove();
	if ($.isFunction(fn))
	{
		fn();
	}
	})
}

}
}

function noright(obj) {
    if (obj) {
        obj.oncontextmenu  =  function() {
            return false;
        }
        obj.ondragstart  =  function() {
            return false;
        }
        obj.onselectstart  =  function() {
            return false;
        }
        obj.onselect  =  function() {
            obj.selection.empty();
        }
        obj.oncopy  =  function() {
            obj.selection.empty();
        }
        obj.onbeforecopy  =  function() {
            return false;
        }
    }
}
noright(document.body);
}
function setTitle(t){
 window.document.title = t;
}




var OPENID = localStorage.openid; //调用方法

function getmyid(){
 
}
$(function(){
	try{
	  var nav = navigator.userAgent.toLowerCase(); //daqsoft.com
	if (nav.indexOf("daqsoft.com") < 0) //app请求不拦截
	{
			var code = getParameter("Code",document.URL);
			//confirm(code + "==="+document.URL);
		  if ( ((localStorage.openid == null || localStorage.openid == undefined  || localStorage.openid == "undefined" || localStorage.openid == "null")  && (code == undefined || code == null)))
		  {
				 window.location.href= "/author.do?shopid="+SHOPSET["id_"+document.domain]+"&callurl="+encodeURIComponent(document.URL);
		  }else if (localStorage.openid == null || localStorage.openid == undefined  || localStorage.openid == "undefined" || localStorage.openid == "null") {
		   //$("body").show();
			 if ( code != null && code != undefined)
			 {
				 var p = {
				   code:code,
				   shopid:SHOPSET["id_"+document.domain]
				 }
				 Wloading3("正在帮定信息,请稍候");
				 $.ajax({
				   url:"/author3.do",
				  // url:"https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx50320f97826231fb&secret=927791adcf31655ec5755709e414069c&code="+code+"&grant_type=authorization_code",
				  data:p,
				  success:function(data){
					if (data.openid == undefined)
					{
						alert("网站配置错误");
					}
				   localStorage.openid = data.openid;
						
						data.shopid = SHOPSET["id_"+document.domain];
						
						requestData2(data,"/setinfo.do",function(data){
						 if ( data == "true")
						 {
							var url = document.URL;
							//
							//window.location.reload();
							//window.location.href = url.replace("Code","passcode");
						 }else{
						  //授权失败;
						 }
						})
				  }
				 });
			 }
		  }
	}
	}catch(e){
	
	}
	//alert(1);

});

var ISET = false;
function getMyInfo(fn){
	if ( localStorage.phone != undefined && localStorage.phone != null && localStorage.phone != "null" && localStorage.phone != "undefined")
	{
      $("#tel").val(localStorage.phone);
	  $("#con").val(localStorage.name);
	  if ($.isFunction(fn))
		   {
			   fn(localStorage.phone);
		   }
	}else{
  requestData2({openid:OPENID,id:SHOPSET["id_"+document.domain]},"/getphone.do",function(data){
    //
     
		 if ( data.phone !="1")
		 {
         localStorage.phone = data.phone;
		 localStorage.name = data.name;
		  $("#tel").val(localStorage.phone);
	      $("#con").val(localStorage.name);
		   if ($.isFunction(fn))
		   {
			   fn(localStorage.phone);
		   }
		 }else{
		   if ($.isFunction(fn))
		   {
			   fn(localStorage.phone);
		   }
		 }
     
  });
	}
}
// 

function getAllINfo(fn){
  requestData2({openid:OPENID,id:SHOPSET["id_"+document.domain]},"/getphone.do",function(data){
    //
     
		 if ( data.phone !="1")
		 {
         //localStorage.phone = data.phone;
		   if ($.isFunction(fn))
		   {
			   fn(data);
		   }
		 }else{
		   if ($.isFunction(fn))
		   {
			  // fn(localStorage.phone);
		   }
		 }
     
  });
}
function setMyInfo(phone,name,fn){

	if ( (localStorage.phone == undefined || localStorage.phone == null || localStorage.phone == "null" || localStorage.phone == "undefined") || localStorage.phone != phone )
	{
  requestData2({openid:OPENID,id:SHOPSET["id_"+document.domain],phone:phone,name:name},"/setphone.do",function(data){
    //
     if (data.success == "true")
     {
		 ISET = true;
         localStorage.phone = phone;
		 localStorage.name = name;
		 if ($.isFunction(fn))
		 {
              fn();
		 }
     }
  });
}else{
	    //
if ($.isFunction(fn))
		 {
              fn();
		 }
	 }
}
//延迟加载
function lazyLoad(url){

}
var NO_MORE = "<p  class='nomore' style='font-size:1.3rem;padding:0px;width:100%;line-height:30px;text-align:center;color:gray;height:30px'>----------哎哟,已经到底啦----------</p>";

/*<p class="collect_wu none" id="no">
		<i class="not_data"></i>
		您暂时没有任何收藏记录
	</p>*/
//var NO_DATA = "<div id='noda' style='width:100%;display:block;height:316px;margin:auto;margin-top:80px;background:url(/frame/images/nodata.png) center 0px no-repeat'></div>";
var NO_DATA ='<p id="noda" class="collect_wu " onclick="window.location.reload()" style="padding-bottom:0.5rem;padding-top:0.7rem!important;color:#A2A2A2;    text-align: center;height: 50px;line-height: 50px;font-size: 1.5rem;" id="no"><i class="not_data" style="margin-bottom:0.5rem!important"></i>无任何记录</p>';
var localhost = "/httprequest.do"; //请求的Url
var remoteUrl="http://api.wopen.tv/api/service/" ;//"http://192.168.0.173:8888/zxw/app/rest";//"http://api.wopen.tv/api/service/"; // 提供接口的服务器地址
var FAIL_DATA ='<p id="faildata" class="collect_wu " onclick="window.location.reload()" style="padding-bottom:0.5rem;padding-top:0.7rem!important;color:#A2A2A2;" id="no"><i class="not_data" style="margin-bottom:0.5rem!important"></i>数据加载失败</p>';
/**
 * 请求方法
 * @param json 数据
 * @param url 接口地址 http://...
 * @param fn 回调函数
 */
function requestData(json,url,fn){
	if (json.shopid == null || json.shopid == undefined){
		alert("参数shopid必须提供,可通过${shopid!}获取");
	}
	Wloading3("请稍等...");
	var start = new Date().getTime();
	//remoteUrl = remoteUrl == ""?localhost:remoteUrl;
	json.remoteUrl= url;
	//json.seccode = "1B793E292678FA7E8F9E2F20C44B359FE64A2F062A267537";
	//json.AppKey = "eda608c2-589f-48ef-8c48-d984edcbdc92";
	//json.AppId = "tJOabi6fooB3";
	$.ajax({
		 type:"POST",
		 url:localhost,
		 data:json,
		 timeout : 15000,
		 success:function(data){
			 closeDialog();
			 fn(data);
		    
			 console.log("本次请求共耗时"+(new Date().getTime()-start)+"ms");
		 },
		 error:function(data){
			  fn("");
			   closeDialog();
			    $(".nomore").remove();
			//alert("请求超时,【<a href='javascript:location.reload()' style='color:red'>重新加载</a>】");
		 }
	});
}
function requestData2(json,url,fn){
	Wloading3("请稍等...");
	var start = new Date().getTime();
	//remoteUrl = remoteUrl == ""?localhost:remoteUrl;
	json.remoteUrl= url;
	//json.seccode = "1B793E292678FA7E8F9E2F20C44B359FE64A2F062A267537";
	//json.AppKey = "eda608c2-589f-48ef-8c48-d984edcbdc92";
	//json.AppId = "tJOabi6fooB3";
	$.ajax({
		 type:"POST",
		 url:url,
		 data:json,
	     timeout : 15000,
		 success:function(data){
			 closeDialog();
			 fn(data);
		    
			 console.log("本次请求共耗时"+(new Date().getTime()-start)+"ms");
		 },
		 error:function(data){
			  fn("");
			   closeDialog();
			    $(".nomore").remove();
			//alert("请求超时,【<a href='javascript:location.reload()' style='color:red'>重新加载</a>】");
		 }
	});
}
function requestData3(json,url,fn){
	//Wloading3("请稍等...");
	var start = new Date().getTime();
	//remoteUrl = remoteUrl == ""?localhost:remoteUrl;
	json.remoteUrl= url;
	//json.seccode = "1B793E292678FA7E8F9E2F20C44B359FE64A2F062A267537";
	//json.AppKey = "eda608c2-589f-48ef-8c48-d984edcbdc92";
	//json.AppId = "tJOabi6fooB3";
	$.ajax({
		 type:"POST",
		 url:url,
		 data:json,
		  timeout : 15000,
		 success:function(data){
			// closeDialog();
			 fn(data);
		    
			 console.log("本次请求共耗时"+(new Date().getTime()-start)+"ms");
		 },
		 error:function(data){
			 fn("");
			  closeDialog();
			   $(".nomore").remove();
			//alert("请求超时,【<a href='javascript:location.reload()' style='color:red'>重新加载</a>】");
		 }
	});
}

function requestData4(json,url,fn){
	var start = new Date().getTime();
	//remoteUrl = remoteUrl == ""?localhost:remoteUrl;
	json.remoteUrl= url;
	//json.seccode = "1B793E292678FA7E8F9E2F20C44B359FE64A2F062A267537";
	//json.AppKey = "eda608c2-589f-48ef-8c48-d984edcbdc92";
	//json.AppId = "tJOabi6fooB3";
	$.ajax({
		 type:"POST",
		 url:localhost,
		 data:json,
			 timeout : 15000,
		 success:function(data){
			 closeDialog();
			 fn(data);
		    
			 console.log("本次请求共耗时"+(new Date().getTime()-start)+"ms");
		 },
		 error:function(data){
			  closeDialog();
			   $(".nomore").remove();
			//alert("请求超时,【<a href='javascript:location.reload()' style='color:red'>重新加载</a>】");
		 }
	});
}

/**
 * 处理无数据，在回调函数里使用
 * @param domid
 * @param total 总数据数
 */
function noData(domid,total){
	
	$(".nomore").remove();
	if ( page == 1)
	{
		$("#"+domid).empty();
		$(".nomore").remove();
		total_ = 0;
	}
total_ = total;
	if ( total == 0){
		$("#noda").remove();
		$("#"+domid).html(NO_DATA);
		return;
	}if ( total == 10)
	{
IsNext = false;
	$(".nomore").remove();
	if ( page !=1 )
	{
$("#"+domid).append(NO_MORE);
		//并且回到顶部图标
	}
	}else if ( total == undefined)
	{
$("#filedata").remove();
		$("#"+domid).html(FAIL_DATA);
	}

}

var total_ = 0;
var tsize = 0;
/**
 * 分页调用,size为当次调用回数据的length,分页需要引用frame/js/page.js
 * @param size 当次调用数据数量
 */
function pageData(domid,size){
	if ( page == 1)
	{
	tsize = 0;
	//total_ = 0;
	}
	tsize+=size;
	if ( size ==0){ //无数据或者取出的数据小于分页数
	IsNext = false;
	$(".nomore").remove();
	if ( page !=1 )
	{
$("#"+domid).append(NO_MORE);
		//并且回到顶部图标
	}
		
	
}else if (tsize >= total_ && page !=1)
	{
IsNext = false;
	$(".nomore").remove();
	$("#"+domid).append(NO_MORE);
	}else if (tsize >= total_ && page == 1) // 初始数据等于总数
	{
		//
IsNext = false;
	$(".nomore").remove();
	if (tsize > 5)
	{
		$("#"+domid).append(NO_MORE);
	}
	
	}

}

var PHONE_REG = /^(([1][358476][0-9]{9})|((\d{3,4})-(\d{7,8})))$/;
/***
 * 管理接口访问的真实地址
 */
var STATIC_URL = {
		local:"http://api.wopen.tv/api/service/"
}
/**
 * 加载遮罩层
 * @param msg
 */

var LOADDATA ="<center style ='color:#82D2D2;font-size:1.5rem;margin:10px 0px;display:inline-block;text-align:center;width:100%;'>数据加载中...</center>";


var EARTH_RADIUS = 6378137.0;    //单位M
var PI = Math.PI;

function getRad(d) {
    return d * PI / 180.0;
}
/**
 * 经纬度换算成距离
 * @param lat1
 * @param lng1
 * @param lat2
 * @param lng2
 * @returns {String}
 */
function getFlatternDistance(lat1, lng1, lat2, lng2) {
    lat1 = Number(lat1);
    lat2 = Number(lat2);
    lng1 = Number(lng1);
    lng2 = Number(lng2);
    console.log(lat1 + "==" + lng1 + "==" + lat2 + "==" + lng2);
    var f = getRad((lat1 + lat2) / 2);
    var g = getRad((lat1 - lat2) / 2);
    var l = getRad((lng1 - lng2) / 2);

    var sg = Math.sin(g);
    var sl = Math.sin(l);
    var sf = Math.sin(f);

    var s, c, w, r, d, h1, h2;
    var a = EARTH_RADIUS;
    var fl = 1 / 298.257;

    sg = sg * sg;
    sl = sl * sl;
    sf = sf * sf;

    s = sg * (1 - sl) + (1 - sf) * sl;
    c = (1 - sg) * (1 - sl) + sf * sl;

    w = Math.atan(Math.sqrt(s / c));
    r = Math.sqrt(s * c) / w;
    d = 2 * w * a;
    h1 = (3 * r - 1) / 2 / c;
    h2 = (3 * r + 1) / 2 / s;
    var re = (Math.round(d * (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg))) / 1000);
    if (isNaN(re)) return "未知距离";
    if (re > 10000) return "未知距离";
    return re.toFixed(2) + " km";
}

function getParameter(paraStr, url) {
    var result = "";
    //获取URL中全部参数列表数据
    var str = "&" + url.split("?")[1];
    var paraName = paraStr + "=";
    //判断要获取的参数是否存在
    if (str.indexOf("&" + paraName) != -1) {
        //如果要获取的参数到结尾是否还包含“&”
        if (str.substring(str.indexOf(paraName), str.length).indexOf("&") != -1) {
            //得到要获取的参数到结尾的字符串
            var TmpStr = str.substring(str.indexOf(paraName), str.length);
            //截取从参数开始到最近的“&”出现位置间的字符
            result = TmpStr.substr(TmpStr.indexOf(paraName), TmpStr.indexOf("&") - TmpStr.indexOf(paraName));
        }
        else {
            result = str.substring(str.indexOf(paraName), str.length);
        }
    }
    else {
        result = "无此参数";
    }
    return (result.replace("&", "").split("=")[1]);
}
/**
 * 获取日期天数
 */
function getdays(a, b) {
	var s1,s2;
	s1 = new Date(a.replace(/-/g, "/"));
	s2 = new Date(b.replace(/-/g, "/"));
	var days = s2.getTime() - s1.getTime();
    return parseInt(days / (1000 * 60 * 60 * 24));
}
var istrue = true;
//微信授权
  function imagePreview(curSrc, srcList) {
           
            //这个检测是否参数为空
            if (!curSrc || !srcList || srcList.length == 0) {
                return;
            }
            //这个使用了微信浏览器提供的JsAPI 调用微信图片浏览器
            WeixinJSBridge.invoke('imagePreview', {
                'current': curSrc,
                'urls': srcList
            });
        }     

function wxInitial(obj,fn){
  //授权
  obj.url = document.location.href;
try{
	//Wtxt("正在定位");
   $.ajax({
     url:"/getsign.action",
	 type:"post",
	 data:obj,
		 success:function(data){
		//$(".windowcenter2").remove();
	    wx.config({
      debug: false,
      appId: obj.appid,
      timestamp: 1421142450,
      nonceStr: 'Wm3WZYTPz0wzccnW',
      signature: data.sign,
      jsApiList: [
        "getLocation","openLocation","onMenuShareTimeline","onMenuShareAppMessage",
		  "onMenuShareQQ","onMenuShareWeibo","onMenuShareQZone"
      ]
  });
	 },error:function(){
		// closeDialog();
	   if ($.isFunction(fn))
		{
			fn();
		}
	 }
     
  });
  
  wx.error(function(res){
	 // closeDialog();
	  if ($.isFunction(fn))
		{
			fn();
		}
   //  alert(JSON.stringify(res));
    // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
//istrue =false;
});
}catch(e){
 istrue = true;
}
return istrue;
}
var latitude=26.362541,longitude=102.365214;
function wxGetPosition(obj,fn){
	

try{
  wxInitial(obj,fn);
  wx.ready(function () {
    wx.getLocation({
    type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
    success: function (res) {
		
         latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
         longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
        var speed = res.speed; // 速度，以米/每秒计
        var accuracy = res.accuracy; // 位置精度
	console.log(latitude+","+longitude);
		//  return latitude+","+longitude;
		if ($.isFunction(fn))
		{
			fn();
		}
    }
});
  })

}catch(e){
 //  return latitude+","+longitude;
}
	
}



//微信导航
function OpenMapLocation(lat, lng, name, address) {
    //alert(lat + ',' + lng + ',' + name + ',' + address);
   try{
      lat = parseFloat(lat);
    lng = parseFloat(lng);
    wx.openLocation({
        latitude:lat,    //23.099994,
        longitude:lng,     //113.324520,
        name: name,
        address: address,
        scale: 14
    });
   }catch(e){
    window.location.href =" http://apis.map.qq.com/tools/routeplan/eword="+name+"&epointx="+lng+"&epointy="+lat+"&navibutton=2?referer=myapp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77";
   }
}

/**
 * 比较日期大小，a > b return true
 * @param a
 * @param b
 * @returns {Boolean}
 */

function timeRather(a, b) {
	var s1,s2;
	s1 = new Date(a.replace(/-/g, "/"));
	s2 = new Date(b.replace(/-/g, "/"));
	var days = s2.getTime() - s1.getTime();
    if (days <= 0) return true;
    else return false;
}
var lat=0,lng=0;
var geolocation,map;
function getLatLng(fn){
	
    SimplePop.load("正在获取您的位置信息");
    //加载地图，调用浏览器定位服务
    
        map = new AMap.Map('mapContainer', {
            resizeEnable: false
        });
        map.plugin('AMap.Geolocation', function () {
            geolocation = new AMap.Geolocation({
                enableHighAccuracy: true, //是否使用高精度定位，默认:true
                timeout: 2000,          //超过6秒后停止定位，默认：无穷大
                maximumAge: 0,           //定位结果缓存0毫秒，默认：0
                convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                showButton: true,        //显示定位按钮，默认：true
                buttonPosition: 'LB',    //定位按钮停靠位置，默认：'LB'，左下角
                buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                showMarker: true,        //定位成功后在定位到的位置显示点标记，默认：true
                showCircle: true,        //定位成功后用圆圈表示定位精度范围，默认：true
                panToLocation: true,     //定位成功后将定位到的位置作为地图中心点，默认：true
                zoomToAccuracy: true      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            });
            map.addControl(geolocation);
            AMap.event.addListener(geolocation, 'complete', function onComplete(data) {
                var str = '<div>定位成功</div>';
                str += '<div>经度：' + data.position.getLng() + '</div>';
                str += '<div>纬度：' + data.position.getLat() + '</div>';
                str += '<div>精度：' + data.accuracy + ' 米</div>';
                str += '<div>是否经过偏移：' + (data.isConverted ? '是' : '否') + '</div>';
                SimplePop.load("位置信息获取成功");
               // mymappos = data.position.getLng() + "," + data.position.getLat();
                lng = data.position.getLng();
                lat = data.position.getLat();
            //Console.log(mymappos);
               // AjaxData();
                if ($.isFunction(fn)){ //判断是否是函数
                	fn();
                }
                
            }); //返回定位信息
            AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
            getCurrentPosition();
        });

    //获取当前位置信息
   
}
function getCurrentPosition() {
    geolocation.getCurrentPosition();
};
//监控当前位置并获取当前位置信息
function watchPosition() {
    geolocation.watchPosition();
};
//解析定位结果

//解析定位错误信息
function onError(data) {
    var str = '';
    switch (data.info) {
        case 'PERMISSION_DENIED':
            str = '浏览器阻止了定位操作';
            break;
        case 'POSITION_UNAVAILBLE':
            str = '无法获得当前位置';
            break;
        case 'TIMEOUT':
            str = '定位超时';
            break;
        default:
            str = '未知错误';
            break;
    }
    SimplePop.alert(str);
}
function navpage(lat,lng,name){
	window.location.href="http://apis.map.qq.com/tools/routeplan/eword="+name+"&epointx="+lng+"&epointy="+lat+"&navibutton=2?referer=myapp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77";
	
}

function callphone(phone){
	window.location.href = "tel:"+phone;
}
function getfulldate(times) {
	var s1;
	s1 = new Date(times);
	return s1.getFullYear()+"-"+(s1.getMonth()+1)+"-"+s1.getDate()+" "+s1.getHours()+":"+s1.getMinutes()+":"+s1.getSeconds();
}
function getnowdate(format) {
	var str = format;   
    var Week = ['日','一','二','三','四','五','六'];  
  var s1;
	s1 = new Date();
    str=str.replace(/yyyy|YYYY/,s1.getFullYear());   
    str=str.replace(/yy|YY/,(s1.getYear() % 100)>9?(s1.getYear() % 100).toString():'0' + (s1.getYear() % 100));   
  
    str=str.replace(/MM/,(s1.getMonth()+1)>9?(s1.getMonth()+1).toString():'0' +(s1.getMonth()+1));   
    str=str.replace(/M/g,(s1.getMonth()+1));   
  
    str=str.replace(/w|W/g,Week[s1.getDay()]);   
  
    str=str.replace(/dd|DD/,s1.getDate()>9?s1.getDate().toString():'0' + s1.getDate());   
    str=str.replace(/d|D/g,s1.getDate());   
  
    str=str.replace(/hh|HH/,s1.getHours()>9?s1.getHours().toString():'0' + s1.getHours());   
    str=str.replace(/h|H/g,s1.getHours());   
    str=str.replace(/mm/,s1.getMinutes()>9?s1.getMinutes().toString():'0' + s1.getMinutes());   
    str=str.replace(/m/g,s1.getMinutes());   
  
    str=str.replace(/ss|SS/,s1.getSeconds()>9?s1.getSeconds().toString():'0' + s1.getSeconds());   
    str=str.replace(/s|S/g,s1.getSeconds());   
  
    return str;  
}
function getnowdateX(i){
  var s1;
	s1 = new Date();
	var time = s1.getTime(); //当前毫秒数
	var t = 1000*3600*24*i;
	console.log(time);
	var times = time+t;
s1 = new Date(times);
return ((s1.getMonth()+1) < 10 ?"0"+(s1.getMonth()+1):(s1.getMonth()+1))+"-"+(s1.getDate()<10?"0"+s1.getDate():s1.getDate());
}

/**
 * 将数据铺到页面
 * @param data 集合数据
 * @param domid 元素id数组
 * 
 */
function pushData(data,domid){
  	if ( data != null){
  		var val = "暂无";
  		$.each(domid,function(i,n){
  			$("#"+n).empty();
  			val = data[n] == null?"暂无":data[n];
  			$("#"+n).html(val);
  		})
  		
  	}
	
}

/*$(function(){
	try{
		
		var mid = SHOPSET["id_"+document.domain];
var statid = SHOPSET["pass_"+mid];

  if ( statid != undefined)
  {


	  jQuery.getScript("/path/to/myscript.js")
    .done(function() {
       
    })
    .fail(function() {
       
});
	  var daq_stat_date = new Date().getTime(); 
//$("body").append(unescape("<span id='daq_stat_icon_"+ statid +"'><script src='http://webstat.stat.geeker.com.cn/daqstat.js?sid="+ statid +"&rnd=" + daq_stat_date + "' type='text/javascript'></script></span>"));
  }
	}catch(ex){
	 console.log(ex.message);
	}
 
});*/